package com.xiaoyu.lanling.feature.profile.model

import `in`.srain.cube.request.JsonData
import com.xiaoyu.base.model.User
import com.xiaoyu.base.utils.ListUtil
import com.xiaoyu.lanling.feature.user.model.UserAlbumItem

class UserProfile(jsonData: JsonData) {
    companion object {
        const val MAX_ALBUM_COUNT = 10
    }

    val user = User.fromJson(jsonData)
    val birthday = jsonData.optString("birthday")
    val constellation = jsonData.optString("constellation")
    val province = jsonData.optString("province")
    val city = jsonData.optString("city")
    val county = jsonData.optString("county")
    val profession = jsonData.optString("profession")
    val height = jsonData.optString("height")
    val weight = jsonData.optString("weight")
    val size = jsonData.optString("size")
    val glamorPlace = jsonData.optString("glamorPlace")
    val annualIncome = jsonData.optString("annualIncome")
    val educationDegree = jsonData.optString("educationDegree")
    val emotionStatus = jsonData.optString("emotionStatus")
    val inhabitStatus = jsonData.optString("inhabitStatus")
    val premaritalLiving = jsonData.optString("premaritalLiving")
    val acceptDates = jsonData.optString("acceptDates")
    val house = jsonData.optString("house")
    val car = jsonData.optString("car")
    val drink = jsonData.optString("drink")
    val cookLevel = jsonData.optString("cookLevel")
    val soliloquy = jsonData.optString("soliloquy")
    val photos = ListUtil.convertToList(jsonData.optJson("photos").asList<String>()) { url -> UserAlbumItem(url) }
}